package com.xiaoran.goods20013.controller;


import com.xiaoran.commonapi.entity.Rst;
import com.xiaoran.goods20013.entity.XrGoods;
import com.xiaoran.goods20013.service.IXrGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xiaoRan
 * @since 2022-02-25
 */
@RestController
@RequestMapping("/xr-goods")
public class XrGoodsController {
    @Autowired
    IXrGoodsService goodsService;
    @Autowired
    Rst rst;

    @PostMapping("/addOne")
    public boolean addOne(XrGoods data) {
        return goodsService.addOne(data) == 1;
    }

    @GetMapping("/getList")
    public Object getByStore(Long storeid, Long gtid) {
        List<XrGoods> list = goodsService.getList(storeid, gtid);
        if (list.isEmpty()) {
            return rst.success(null);
        }
        return rst.success(list);
    }
}
